''''
平均优化
二：2元一次方程
三：3元一次方程
四：元一次方程
。。。。

'''

class Avgb():
    def __init__(self):
        pass
    def toshow(self,res):
        for r in res:
            print(f'赔率：{r.get("ps")}  购买：{r.get("bei")}倍 金额：{r.get("total")}元 奖金：{r.get("jiang")}元')
    # 两个赔率进行优化
    def get2(self,a,b,c):
        y = a * c / (2 * a + 2 * b)
        x = b*y/a
        xb = int(round(x,0))
        yb = int(round(y,0))
        plist = [{"ps":a,"bei":xb,"total":2*xb,"jiang":round(xb*a*2)},{"ps":b,"bei":yb,"total":2*yb,"jiang":round(yb*b*2)}]
        return plist
    # 3个赔率进行优化
    def get3(self,a,b,c,d):
        y = (a * c * d)/(2 * a * c + 2 * c * b + 2 * b * a)
        x = (b * y) / a
        z = (b * y) / c
        xb = int(round(x,0))
        yb = int(round(y,0))
        zb = int(round(z, 0))
        plist = [{"ps":a,"bei":xb,"total":2*xb,"jiang":round(xb*a*2)},{"ps":b,"bei":yb,"total":2*yb,"jiang":round(yb*b*2)},{"ps":c,"bei":zb,"total":2*zb,"jiang":round(zb*c*2)}]
        return plist

if __name__ == '__main__':
    avg = Avgb()
    res = avg.get3(9.5,3.84,4.5,100)
    # res = avg.get2(2.27, 3.81, 100)
    avg.toshow(res)
